//
//  CustomLabel.swift
//  DataStructure
//
//  Created by kys-20 on 2019/8/27.
//  Copyright © 2019 kys-20. All rights reserved.
//

import Foundation
import UIKit
class CustomLabel: UILabel {
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUpUI()
    }
    private func setUpUI(){
        self.layer.masksToBounds = true
        self.layer.borderWidth = 1
        self.layer.borderColor = UIColor.black.cgColor
        self.textColor = UIColor.black
        self.textAlignment = .left
        
        
    }
    override func draw(_ rect: CGRect) {
        super.draw(rect)
        let path = UIBezierPath()
        let shapeLayer = CAShapeLayer()
        //        if self.frame.width == self.frame.height{
        //             path.move(to: CGPoint(x: 0, y: 0))
        //             path.addLine(to: CGPoint(x: self.frame.width, y: self.frame.height))
        //        }else{
        path.move(to: CGPoint(x: self.frame.width*(3/4), y: 0))
        path.addLine(to: CGPoint(x: self.frame.width*(3/4), y: self.frame.height))
        //        }
        path.close()
        shapeLayer.strokeColor = UIColor.red.cgColor
        shapeLayer.fillColor = UIColor.clear.cgColor
        shapeLayer.lineWidth = 1
        shapeLayer.lineJoin = CAShapeLayerLineJoin.round
        shapeLayer.lineCap = CAShapeLayerLineCap.round
        shapeLayer.path = path.cgPath
        shapeLayer.strokeStart = 0
        shapeLayer.strokeEnd = 1
        path.fill()
        path.stroke()
    }

    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
